package com.sline.file;

import java.io.File;
import java.io.FilenameFilter;

public class Demo6_FilenameFilter {
    public static void main(String[] args) {
        File dir = new File("/Users/luchengdong/Downloads");

        String[] arr = dir.list(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {

                File file = new File(dir, name);
                return file.isFile() && file.getName().endsWith("pdf");
            }
        });

        for (String string: arr) {
            System.out.println(string);
        }
    }
}
